#if !defined CNTRLLRSOB
#define CNTRLLRSOB

#include "cv.h"
#include "sobel.h"
#include "aviprocessor.h"
#include "process.h"

#include <vector>  

class SobelVideoController {

private:

	static SobelVideoController *singleton; // pointer to the singleton

	AviProcessor *aviproc;
	Sobel *sobel;

	SobelVideoController() { // private constructor

		//setting up the application
		aviproc= new AviProcessor();
		sobel= new Sobel();
		aviproc->setImageProcess(process);
		aviproc->callProcess();
		aviproc->setDisplay(true);
	}

public:

	void run() {

		aviproc->run();
	}

	void stop() {

		aviproc->stopIt();
	}

	// to be called by the callback
	inline void processImage(IplImage *image) {

		//use openmp to process the image
		sobel->processImageOpenMP(image);
		//sobel->processImage(image);
	}

	inline void setFile(CString filename) {

		aviproc->setFile(filename);
	}

	inline IplImage* getOutputImage() {

		return sobel->getOutputImage();
	}

	~SobelVideoController() {

		delete aviproc;
		delete sobel;
	}

	// Singleton static members
	static SobelVideoController *getInstance() {

		if (singleton == 0)
			singleton= new SobelVideoController;

		return singleton;
	}

	static void destroy() {

		if (singleton != 0) {
			delete singleton;
			singleton= 0;
		}
	}
};

#endif
